package cn.kgc.easybuy.service.impl;

import cn.kgc.easybuy.dao.BuyCarMapper;
import cn.kgc.easybuy.pojo.BuyCar;
import cn.kgc.easybuy.service.BuyCarService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @program: yingzi-wants-to-sleep
 * @description:
 * @author: 敖成
 * @create: 2025-09-18 16:30
 **/
@Service
@Transactional
public class BuyCarServiceImpl implements BuyCarService {
    @Autowired
    private BuyCarMapper buyCarMapper;


    @Override
    public PageInfo<BuyCar> selectBuyCarByPage(Map<String, Object> params) {
        PageHelper.startPage(params);
        return new PageInfo<BuyCar>(buyCarMapper.selectBuyCarByUserId(params));
    }

    @Override
    public boolean addBuyCar(BuyCar buyCar) {
        return buyCarMapper.addBuyCar(buyCar) > 0;
    }

    @Override
    public boolean updateBuyCar(BuyCar buyCar) {
        return buyCarMapper.updateBuyCar(buyCar) > 0;
    }

    @Override
    public boolean deleteBuyCarById(int id) {
        return buyCarMapper.deleteBuyCarById(id) > 0;
    }

    @Override
    public boolean deleteBuyCarByUserId(Integer userId) {
        return buyCarMapper.deleteBuyCarByUserId(userId) > 0;
    }

    @Override
    public BuyCar addBuyCarNum(int userId, int pid) {
        return buyCarMapper.addBuyCarNum(userId, pid);
    }

    @Override
    public List<BuyCar> selectAllBuyCar(Integer userId) {
        return buyCarMapper.selectAllCar(userId);
    }
}
